#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
bool judge(ll n){
    if(n%400==0||(n%100!=0&&n%4==0)){
        return true;
    }
    return false;
}
ll month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
    IOS;
    ll y,m,d,n;
    while(cin>>y>>m>>d>>n){
        n+=d;
        bool fin=false;
        for(ll i=m;;){
            if(i==0)i=12;
            if(judge(y)&&i==2){
                if(n>29){
                    n-=29;
                }
                else {
                    printf("%lld-%02lld-%02lld\n",y,i,n);
                    break;
                }
            }
            else {
                if(n>month[i]){
                    n-=month[i];
                }
                else {
                    printf("%lld-%02lld-%02lld\n",y,i,n);
                    break;
                }
            }
            i=(i+1)%12;
            if(i==1){
                y++;
            }
        }
        // if(fin)continue;

    }
    getchar();
    getchar();
    return 0;
}
